package com.hzw.saas.web.app.user.enums;

import com.hzw.saas.common.config.util.AssertUtil;

/**
 * <p>
 * 验证类型
 * </p>
 *
 * @author sonam
 * @since 2021/1/28 11:28
 */
public enum VerifyMode {

    PHONE(1,"手机验证"),
    EMAIL(2, "邮箱验证"),
    ;

    private final int code;
    private final String text;

    VerifyMode(int code, String text) {
        this.code = code;
        this.text = text;
    }

    public int value() {
        return code;
    }

    public String text() {
        return text;
    }

    public static VerifyMode instance(int value) {
        return instance(value, false);
    }

    public static VerifyMode instance(int value, boolean thrNotFound) {
        for (VerifyMode smsType : values()) {
            if (smsType.value() == value) {
                return smsType;
            }
        }
        AssertUtil.assertThrow("验证模式异常", thrNotFound);
        return null;
    }

}
